home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Filezilla Server / FileZilla_Server-0_9_41.exe / source / interface / ConnectDialog.cpp < prev    next >
C/C++ Source or Header  |  2011-11-06  |  3KB  |  109 lines

  1. // FileZilla Server - a Windows ftp server
  2.  
  3. // Copyright (C) 2002-2004 - Tim Kosse <tim.kosse@gmx.de>
  4.  
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9.  
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. // ConnectDialog.cpp: Implementierungsdatei
  20. //
  21.  
  22. #include "stdafx.h"
  23. #include "filezilla server.h"
  24. #include "ConnectDialog.h"
  25. #include "Options.h"
  26.  
  27. #if defined(_DEBUG) && !defined(MMGR)
  28. #define new DEBUG_NEW
  29. #undef THIS_FILE
  30. static char THIS_FILE[] = __FILE__;
  31. #endif
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // Dialogfeld CConnectDialog 
  35.  
  36.  
  37. CConnectDialog::CConnectDialog(COptions *pOptions)
  38.     : CDialog(CConnectDialog::IDD, NULL)
  39. {
  40.     ASSERT(pOptions);
  41.     m_pOptions = pOptions;
  42.     //{{AFX_DATA_INIT(CConnectDialog)
  43.     m_ServerAddress = _T("");
  44.     m_ServerPassword = _T("");
  45.     m_ServerPort = _T("");
  46.     m_bAlways = FALSE;
  47.     //}}AFX_DATA_INIT
  48. }
  49.  
  50.  
  51. void CConnectDialog::DoDataExchange(CDataExchange* pDX)
  52. {
  53.     CDialog::DoDataExchange(pDX);
  54.     //{{AFX_DATA_MAP(CConnectDialog)
  55.     DDX_Text(pDX, IDC_CONNECTDIALOG_ADDRESS, m_ServerAddress);
  56.     DDX_Text(pDX, IDC_CONNECTDIALOG_PASSWORD, m_ServerPassword);
  57.     DDX_Text(pDX, IDC_CONNECTDIALOG_PORT, m_ServerPort);
  58.     DDV_MaxChars(pDX, m_ServerPort, 5);
  59.     DDX_Check(pDX, IDC_CONNECTDIALOG_ALWAYS, m_bAlways);
  60.     //}}AFX_DATA_MAP
  61. }
  62.  
  63.  
  64. BEGIN_MESSAGE_MAP(CConnectDialog, CDialog)
  65.     //{{AFX_MSG_MAP(CConnectDialog)
  66.     //}}AFX_MSG_MAP
  67. END_MESSAGE_MAP()
  68.  
  69. /////////////////////////////////////////////////////////////////////////////
  70. // Behandlungsroutinen fⁿr Nachrichten CConnectDialog 
  71.  
  72. BOOL CConnectDialog::OnInitDialog() 
  73. {
  74.     CDialog::OnInitDialog();
  75.     
  76.     m_ServerAddress = m_pOptions->GetOption(IOPTION_LASTSERVERADDRESS);
  77.     m_ServerPort.Format(_T("%d"), static_cast<int>(m_pOptions->GetOptionVal(IOPTION_LASTSERVERPORT)));
  78.     m_ServerPassword = m_pOptions->GetOption(IOPTION_LASTSERVERPASS);
  79.     m_bAlways = m_pOptions->GetOptionVal(IOPTION_ALWAYS) != 0;
  80.     UpdateData(FALSE);
  81.  
  82.     return TRUE;  // return TRUE unless you set the focus to a control
  83.                   // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurⁿckgeben
  84. }
  85.  
  86. void CConnectDialog::OnOK() 
  87. {
  88.     UpdateData();
  89.  
  90.     if (m_ServerAddress == _T(""))
  91.     {
  92.         AfxMessageBox(_T("Please enter a server address."), MB_ICONEXCLAMATION);
  93.         return;
  94.     }
  95.  
  96.     if (_ttoi(m_ServerPort)<1 || _ttoi(m_ServerPort)>65535)
  97.     {
  98.         AfxMessageBox(_T("Please enter a server port in the range from 1 to 65535."), MB_ICONEXCLAMATION);
  99.         return;
  100.     }
  101.  
  102.     m_pOptions->SetOption(IOPTION_LASTSERVERADDRESS, m_ServerAddress);
  103.     m_pOptions->SetOption(IOPTION_LASTSERVERPORT, _ttoi(m_ServerPort));
  104.     m_pOptions->SetOption(IOPTION_LASTSERVERPASS, m_ServerPassword);
  105.     m_pOptions->SetOption(IOPTION_ALWAYS, m_bAlways);
  106.  
  107.     CDialog::OnOK();
  108. }
  109.